|
|
|
|
|
DCX vs MDX |
What makes DCX that much better as MDX ? (also a mini DCX tutorial) |
|
|
Author: |
Mpdreamz |
Required knowledge: |
Dialogs, decent understanding mircscripts and a general idea of what MDX and DCX do. |
|
|
| Building your dialogs: |
| |
| In DCX: |
|
In DCX you only define size,title and option in the dialog table, since DCX doesnt work with childcontrols you dont add any control in the dialog table.
dialog tablename {
title "Your dialogstitle"
size x y w h
option pixel size
}
This is the basis point to start your dialog. Then in the init event for this dialog you start to insert controls and modify dialog attributes using /xdialog and modify controls with the /xdid commands.
/xdid and /xdialog are 2 aliases for sending parameters to the dll, although you can call the dll directly using /dll /xdid and /xdialog are still recommended because if you use /dll the syntax is slightly different. They both come with the dll and can be found in the example script.
on *:DIALOG:tablename:init:*: {
var %x = $dcx( Mark,$dname callbackalias)
xdialog -g $dname +b $rgb(0,0,255)
xdialog -c $dname 1 divider 0 0 200 400
xdid -l $dname 1 10 10 $chr(9) 2 panel 0 0 200 200
xdid -r $dname 1 10 10 $chr(9) 3 panel 0 0 200 200
}
In order of appearance this will Mark the dialog to DCX (manditory) and set a callbackalias, something ill get back to you about later. Make the dialog background blue insert a divider and insert a panel in the divider above the move handle and a panel below the move handle. Thats it!
Another enourmous plus of DCX is the introduction of Container controls
i.e. Panel, Tab, Divider, Rebar, Box (a dialog is a container since it
contains child controls even thought we don't refer it as such) that allow you to dock controls into other controls without having to script its behaviour (i.e. For a divider you dont have to script the sizing of controls DCX does this for you!). Its also insanely handy if you need to disable a bunch of controls, if their part of a container control (i.e. a panel thats basicly a borderless dialog in a dialog) you only have to disable the container ID.
|
| |
| In MDX: |
MDX uses child controls, this means that it will take a default mIRC dialog control on the dialog and modify this to another control so in the dialog table you insert all the childcontrols and put them into place.
dialog mp3pl {
size -1 -1 221 342
title "Mp3 player"
list 1,2 172 217 136,extsel size
list 2,2 313 217 30, size
}
Where list 1 and list 2 will act as a childcontrol for a ListView and a ToolBar. This method has drawbacks, such as: use a control property on the child that MDX doesnt like and you'll notice your MDX control will function inproperly. MDX converts the child controls in the init event of the dialog.
on *:dialog:mp3pl:init:*:{
dll c:\mdx.dll SetMircVersion $version
dll c:\mdx.dll MarkDialog $dname
dll c:\mdx.dll SetControlMDX $dname 1 ListView report noheader nosortheader single $&
showsel twoclick > C:\views.mdx
dll c:\mdx.dll SetControlMDX $dname 2 Toolbar flat list wrap nodivider arrows > C:\bars.mdx
}
MDX requires the SetMircVersion and Mark command for it to work, after that it will convert the list with id 1 into a ListView and the list with id 2 into a toolbar. You also might notice it needs to reference to diffent .MDX files for it to convert. A huge drawback with this is that you have to package these files with your scripts. DCX doesnt have this and relies soully on the dll file. |
| |
| Event Handling: |
| |
i
| In DCX: |
Remember the callback alias in the mark command ?, well this alias will take care of everything your dialog and controls trigger. Everytime somthing happens in/with the dialog this command is triggered. DCX.dll will send the folowing parameters to it.
Dialogname Event ID extrainformation (such as the Nth selected item in a treeview)
alias callbackalias {
if ($1 == MyDialogName) {
if ($2 == EventIwantToCatch) {
if ($3 == IdIwantToCatchfor this event) {
if ($4 == extra information you want) {
do something
}
}
}
}
}
And thats it!. This is just an example of course you can format this however you wish.
|
i
| In MDX: |
One of the confusing things with MDX was there are a couple a methods you have to use to get what you want, since MDX used mIRC child controls you could catch the events in a on *:dialog:dialogname:event:id: { in many cases this reguired multiple $gettoks for instance look at this example:
on *:dialog:dialogname:sclick:id: {
did -i $dname $did 1 page event
echo -a $gettok($gettok($did($did,$gettok($did($did,1),3,32)),1,9),7-,32)
}
All this does is get the text of the selected item in a treeview, doesnt really look workable does it ? in DCX it can be catched using
a simple $xdid(dialogname, id, path).text.
To make matters even worse for alot of information you have to request using the page command. DCX eliminates the constant confusion of do i need $did or do page for info and also eliminates the need to format your input using $gettok's such as in the example above. |
| |
| Sizing: |
| |
| In DCX: |
DCX resizing is a charm thanks to a technique called Cell Layout Algorithm (CLA), this is what going to make 2006 the year for professional gui's in mirc. CLA are rules you set on a dialog that says how to size the controls. The structure is alot like html's <table> <tr> <td>, it might take sometime to learn but once mastered the days you worry about allignment are over! Take a look at this example, its from a mediaplayer i am doing which allowes for the dialog to be resized,maximized you can hide the playlist and if the playlist is shown, use a divider to give the playlist more or less room on the dialog.
xdid -l $dname 2 root $chr(9) +p 0 0 0 0
xdid -l $dname 2 cell root $chr(9) +li 6 1 0 0
xdid -l $dname 2 cell root $chr(9) +fvi 8 1 0 0
xdid -l $dname 2 space 2 $chr(9) + 0 0 0 $gettok($xdid($dname,9).pos,4,32)
xdid -t $dname 4 +l 0 200 Playlist: 0 files
xdid -l $dname 3 root $chr(9) +ph 0 0 0 0
xdid -l $dname 3 space root $chr(9) + 0 0 0 0
xdid -l $dname 3 cell root $chr(9) +li 4 1 0 0
xdid -l $dname 3 space 1 $chr(9) + 0 0 0 $gettok($xdid($dname,5).pos,4,32)
xdialog -l $dname root $chr(9) +p 0 0 0 0
xdialog -l $dname cell root $chr(9) +li 1 1 0 0
.timer 1 0 xdialog -l $dname update
.timer 1 0 xdid -l $dname 2 update
.timer 1 0 xdid -l $dname 3 update
Thats its! from now all resizing is done the dll. no more $calc ! To hide the playlist i only need to disable it the sizing is then done as if the playlist isnt a part of it anymore. If you want to learn CLA have a look at my tutorial here
|
| In MDX: |
In MDX You take sizing into acount using the size signals for divider(s) and the dialog. You then $calc all the positions for each individual control accordingly to the values returned by MDX. You dont have to be a mircscripting veteran to know that alot of $calcing lags and eats CPU, so does sizing in MDX. The following code achieves the same effect for my mediaplayer but then in MDX
on *:dialog:mamp2:*:7: {
tokenize 32 $did(7)
if ($devent != sclick) { set %mamp.list.y $1- }
if ($devent == sclick) {
if ($1 == moving) && ($calc($dialog(mamp2).h - $4) <= 80 ) {
/did -a $dname 7 restrict bottom $calc($4 - 7)
}
if ($1 == moving) && ($3 < 143) { /did -a $dname 7 restrict top 143 }
if ($1 == move) && (%mamp2.hide == 8) {
var %q = $calc($dialog(mamp2).h - 200) , %h = $calc($3 - 141)
mdx MoveControl mamp2 4 * $3 * $calc(%q - %h)
mdx MoveControl mamp2 3 * $calc(86 + %h) * *
mdx MoveControl mamp2 2 * $calc(113 + %h) * *
mdx MoveControl mamp2 1 * * * $calc(86 + %h)
}
}
}
on *:dialog:mamp2:sclick:5: {
tokenize 32 $did(5)
if ($1 == sizing) {
if (($6 <= 380) || ($5 < 263 )) && (%mamp2.hide == 8) { /did -a $dname 5 setsize w 267 384 }
if (($6 <= 150) || ($5 < 263 )) && (%mamp2.hide == 9) { /did -a $dname 5 setsize w 267 150 }
}
if ($1 == size) {
var %w = $dialog(mamp2).w , %h = $dialog(mamp2).h
var %c = $calc(%w - 8)
var %div = $calc($gettok(%mamp.list.y,3,32) - 141)
mdx MoveControl mamp2 1 * * %c $iif(%mamp2.hide == 9,$calc(%h - 90),*)
mdx MoveControl mamp2 2 * $iif(%mamp2.hide == 9,$calc(%h - 60),*) %c *
mdx MoveControl mamp2 3 * $iif(%mamp2.hide == 9,$calc(%h - 90),*) %c *
mdx MoveControl mamp2 4 * * %c $calc((%h - 200) - %div)
mdx MoveControl mamp2 7 * $calc(%h - 240) %c *
mdx MoveControl mamp2 6 * $calc(%h - 55) %c *
did -i $dname 4 1 headerdims $calc(%c - 90) 70
vissize
}
}
on *:dialog:mamp2:close:*: {
set %mamp.list.y %x OK 0 143 254 8
}
You can imagine this is horrible to code and horrible in execution. This is even without sizing support for when the dialog is maximized, imagine the bulk if it was included :O |
| |
| |
| General dialog |
DCX |
MDX |
Total size: |
187kb |
172kb |
|
amount of needed files: |
1 |
5 |
|
Ammount of added controls: |
30 |
17 |
|
Create controls on the fly: |
|

(DynamicControl is useless as it cant recieve sclicks) |
|
Modify control Styles on the fly: |
|
|
|
Modify borders/colours on the fly: |
|
|
|
Dialog Animations: |
|
|
|
Command to minimize and maximize dialog: |
|
|
|
Identify Visible Controls: |
|
|
|
Get a controls x y w h: |
|
|
|
Identify enabled/disabled controls: |
|
|
|
Move controls: |
 
Using Cell layout algorithm you can set sizing rules, works like a charm. |

Though it should really be said that MDX relies on crappy $calc coding and is eating alot of CPU. |
|
Change dialog icon: |
|
|
|
Change dialog background and borders: |
|
|
|
Mark controls (add description): |
|
|
|
Drag & Drop support: |
 (not yet) |
|
|
| |
|
|
|
| Calendar |
|
|
|
| WebControl |
|
|
|
| Rebar |
|
|
|
| Panel |
|
|
|
| Tab |
|
|
|
| RichEdit |
|
|
|
| ColorCombo |
|
|
|
| Button |
|
|
|
| Treeview |
|
|
|
Events: |
Has a dclick event that MDX lacks, it fired when expend/collapse though this doesnt have to be the case. |
Das a labeledit event that DCX lacks. |
|
Auto Sorting: |
Using xdid auto sorting can be advanced based on alot of criteria. |
Only ascending alpha numerical sort using control style so this cant be changed after creation. |
|
Per line colouring: |
|
|
|
Path determination method: |
Easy,path is part of the command which you read from right to left. 1 2 3 means the 3rd item of the 2nd item of the 1st item.
|
Hard, Uses a directory kind of structure in which you have to give browse commands before you can add items. |
|
| |
|
|
| Listview |
|
|
|
Events: |
Equal to eachother. |
Equal to eachother. |
|
Control Styles: |
Subitems icon's are supported. |
Has a nosortheader which allows you to have a buttonless header and has a few more options to the hottrack style. |
|
Subitem images: |
|
|
|
Column icons |
|
|
|
Per line colouring of text and background colours: |
|
|
|
Dropdowns and progressbars in an item: |
Will be added however not available in the current beta. |
|
|
$xdid/$did information: |
Lacks information on the headerdims. |
|
|
| |
|
|
| Toolbar |
|
|
|
Events: |
Has the much wanted rclick event!, a dropdown event for arrows that also returns the suggested x and y for the popup. |
|
|
Control styles: |
Has a transparent style so the toolbars background is transparent. |
|
|
Per item colouring + Bolding of text: |
|
|
|
Autosizeitems to full width: |
|
|
|
| |
|
|
| Progressbar |
|
|
|
Events: |
Has 4 events sclick rclick mousebar and help. |
Has no events. |
|
Styles: |
Has a Marquee style MDX lacks. |
|
|
Text in Progressbar: |
|
|
|
| |
|
|
| ComboEx |
|
|
|
Events: |
Has a return event when Enter is pressed in the edit that MDX lacks. |
|
|
| |
|
|
| Trackbar: |
|
|
|
Events: |
Misses selection events as selection is not supported. |
|
|
Selection: |
|
|
|
| |
|
|
| UpDown |
|
|
|
Events: |
Misses a up & down event. This can be determined from sclick though. |
|
|
Align Updown left or right: |
|
|
|
Dock to a text control: |
|
|
|
| |
|
|
| IpAddress |
|
|
|
Set individual field ranges: |
|
|
|
Set focus on a field: |
|
|
|
| |
|
|
| Docked @windows |
|
|
|
Events: |
Misses a whole bunch of mouse events that MDX has. |
|
|
Dock more then 1 @window: |
|
|
|
Capture mouse in @window: |
|
|
|
| |
|
|
| Divider |
|
|
|
| |
The divider control in MDX and DCX differ so much all they really have in common is the name. |
|
| |
In DCX a diver is a moving bar that you "dock" 2 controls to (or a panel that hosts unlimited controls) By moving this bar the docked childs are automaticly sized. Its also posible to have a divider in a divider in a divider etc etc. |
In mdx the Divider is a sizing bar that you can move around and in combination with MoveControl and $calc can adjust control's sizes. |
|
|
|
|
Copyright © mIRC Scripting Network 1999-2012.
If you have found a bug, please send a pmsg to wiggle or tye (pmsg).
Page compiled in 0.029s.
|
| | | |
91 visitors online (0 registered / 91 guests).
Using GZIP Compression. You just ate 10.69 kb of our traffic.
| | |
|
|
|
|